 fun printInt (a:int) =
    print(Int.toString(a)^"\n");

fun getInt () =
    Option.valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn);

fun printIntList ( [] ) = ()
  | printIntList ( x::xs ) = 
    let
	val tmp = printInt(x)
    in
	printIntList(xs)
    end;

fun getIntList ( 0 ) = []
  | getIntList ( N:int) = getInt()::getIntList(N-1);

fun printBool (a:bool) =
    print(Bool.toString(a)^"\n");

   
(*  完成Begin和End间代码的编写  *)
(***   Begin    ***)

(* exists: ('a -> bool) -> 'a list -> bool *)
(* REQUIRES: p: t -> bool, L: t list *)
(* ENSURES: returns true if there exists an x in L such that p x = true; false otherwise. *)
fun exists (p: 'a -> bool) (lst: 'a list) =
    case lst of
        [] => false
      | x::xs => if p x then true else exists p xs;

(* forall: ('a -> bool) -> 'a list -> bool *)
(* REQUIRES: p: t -> bool, L: t list *)
(* ENSURES: returns true if for every x in L, p x = true; false otherwise. *)
fun forall (p: 'a -> bool) (lst: 'a list) =
    case lst of
        [] => true
      | x::xs => if p x then forall p xs else false;




(***	End		***)
fun isOdd 0 = false
  | isOdd 1 = true
  | isOdd n = isOdd (n-2);
  
val x = getIntList (5);

printBool((exists isOdd x) andalso (forall isOdd x));
